import { Component, OnInit } from "@angular/core"
import { Result } from "src/common/result"
import { LoginUser } from "../login-user"
import { User, UserService } from "../user.service"

@Component({
  selector: "app-login",
  templateUrl: "./login.component.html",
  styleUrls: ["./login.component.scss"],
})
export class LoginComponent {
  model: LoginUser
  constructor(private us: UserService) {
    this.model = new LoginUser("13186019285", "111")
  }
  login(e, f) {
    console.log("in login", e, f, this.model)
    this.us.login(this.model).subscribe({
      next: (data: Result<User>) => {
        if (data.success) {
          alert("success")
        } else {
          alert("fail")
        }
      },
      error: (error) => {
        console.log("error")
        alert("fail error")
      },
    })
  }
}
